<html>
<head><meta charset="utf-8"><title>When can we do a partial stabilization of Neon intrinsics? · t-libs · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/index.html">t-libs</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/When.20can.20we.20do.20a.20partial.20stabilization.20of.20Neon.20intrinsics.3F.html">When can we do a partial stabilization of Neon intrinsics?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="235124201"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/When%20can%20we%20do%20a%20partial%20stabilization%20of%20Neon%20intrinsics%3F/near/235124201" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/When.20can.20we.20do.20a.20partial.20stabilization.20of.20Neon.20intrinsics.3F.html#235124201">(Apr 19 2021 at 03:58)</a>:</h4>
<p><a href="https://github.com/rust-lang/stdarch/issues/1125">https://github.com/rust-lang/stdarch/issues/1125</a></p>



<a name="235124409"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/When%20can%20we%20do%20a%20partial%20stabilization%20of%20Neon%20intrinsics%3F/near/235124409" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/When.20can.20we.20do.20a.20partial.20stabilization.20of.20Neon.20intrinsics.3F.html#235124409">(Apr 19 2021 at 04:01)</a>:</h4>
<p>The story here is that blocking all of Neon on having 100% of the intrinsics covered is... a poor user experience. People have been at it off and on for years, and we're only up to like 37% coverage.</p>
<p>However, what's already been added is perfectly functional as is, so we could stabilize just some of  them. Since the API is "we will do what the vendor says" there's no chance of an unexpected design change later on the more we put in.</p>
<p>(This is also a T-lang tangential issue, since it's technically intrinsics, but it's mostly T-libs I think)</p>



<a name="235132911"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/When%20can%20we%20do%20a%20partial%20stabilization%20of%20Neon%20intrinsics%3F/near/235132911" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/When.20can.20we.20do.20a.20partial.20stabilization.20of.20Neon.20intrinsics.3F.html#235132911">(Apr 19 2021 at 06:23)</a>:</h4>
<p>One thing that would make me more comfortable with partial stabilization is a test that checks that the stdarch intrinsics behave identically to the C versions with random inputs.</p>



<a name="235180065"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/When%20can%20we%20do%20a%20partial%20stabilization%20of%20Neon%20intrinsics%3F/near/235180065" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Bramley <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/When.20can.20we.20do.20a.20partial.20stabilization.20of.20Neon.20intrinsics.3F.html#235180065">(Apr 19 2021 at 13:28)</a>:</h4>
<p>Is there anything we (Arm) can do to help here? Our intention was to improve the intrinsics coverage, and to that end <span class="user-mention" data-user-id="309977">@Jamie Cunliffe</span> has experimented with generating them. We put that on hold because we hit some snags, and saw the recent PRs extending the coverage using a different approach, but we think we can repurpose what he's done to generate tests.</p>



<a name="235189132"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/When%20can%20we%20do%20a%20partial%20stabilization%20of%20Neon%20intrinsics%3F/near/235189132" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/When.20can.20we.20do.20a.20partial.20stabilization.20of.20Neon.20intrinsics.3F.html#235189132">(Apr 19 2021 at 14:25)</a>:</h4>
<p><span class="user-mention" data-user-id="143274">@Amanieu</span> if there are bugs, do you think they'll require changing the API? If not, I don't know if the intrinsics need to be unstable just because they might be buggy, the best way to catch bugs is for people to use them.</p>



<a name="235189295"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/When%20can%20we%20do%20a%20partial%20stabilization%20of%20Neon%20intrinsics%3F/near/235189295" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/When.20can.20we.20do.20a.20partial.20stabilization.20of.20Neon.20intrinsics.3F.html#235189295">(Apr 19 2021 at 14:26)</a>:</h4>
<p>It's possible some API changes might be required, for example if an AArch64-only intrinsic was exposed on ARM.</p>



<a name="235196832"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/When%20can%20we%20do%20a%20partial%20stabilization%20of%20Neon%20intrinsics%3F/near/235196832" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/When.20can.20we.20do.20a.20partial.20stabilization.20of.20Neon.20intrinsics.3F.html#235196832">(Apr 19 2021 at 15:07)</a>:</h4>
<p><span class="user-mention" data-user-id="399135">@Jacob Bramley</span> That's great if you already have something that mostly works, we're happy to accept it!</p>



<a name="235196946"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/When%20can%20we%20do%20a%20partial%20stabilization%20of%20Neon%20intrinsics%3F/near/235196946" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/When.20can.20we.20do.20a.20partial.20stabilization.20of.20Neon.20intrinsics.3F.html#235196946">(Apr 19 2021 at 15:08)</a>:</h4>
<p>Ideally we would want something that could work for both ARM and x86 intrinsics, but if your version is only applicable to ARM then that's fine too.</p>



<a name="235220560"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/When%20can%20we%20do%20a%20partial%20stabilization%20of%20Neon%20intrinsics%3F/near/235220560" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/When.20can.20we.20do.20a.20partial.20stabilization.20of.20Neon.20intrinsics.3F.html#235220560">(Apr 19 2021 at 17:45)</a>:</h4>
<p>wouldn't we be stabilizing on an intrinsic by intrinsic basis, and thus we'd be checking off the intriniscs to be stabilized against some sort of list from some sort of place?</p>



<a name="235228121"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/When%20can%20we%20do%20a%20partial%20stabilization%20of%20Neon%20intrinsics%3F/near/235228121" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/When.20can.20we.20do.20a.20partial.20stabilization.20of.20Neon.20intrinsics.3F.html#235228121">(Apr 19 2021 at 18:38)</a>:</h4>
<p>I would ideally like to see ASIMD1 and ASIMD2 treated as if they were more distinct entities, since they kind of are, even if they seem to offer (mostly?) the same API.<br>
I would definitely like to see ASIMD1 and ASIMD2 <em>tested</em> as if they were distinct entities.</p>



<a name="235230236"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/When%20can%20we%20do%20a%20partial%20stabilization%20of%20Neon%20intrinsics%3F/near/235230236" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/When.20can.20we.20do.20a.20partial.20stabilization.20of.20Neon.20intrinsics.3F.html#235230236">(Apr 19 2021 at 18:54)</a>:</h4>
<p>is asimd1 the simd for ARM 32-bit devices and then asimd2 is the simd for Aarch64 devices?</p>



<a name="235232132"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/When%20can%20we%20do%20a%20partial%20stabilization%20of%20Neon%20intrinsics%3F/near/235232132" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/When.20can.20we.20do.20a.20partial.20stabilization.20of.20Neon.20intrinsics.3F.html#235232132">(Apr 19 2021 at 19:06)</a>:</h4>
<p>Yeah, ASIMD1 is Arm v7's "Neon", and ASIMD2 is Arm v8's "Neon", and I believe the targets of interest are ASIMD1 programs on Arm v7 devices, ASIMD2 programs on aarch64, and programs using "Neon" on aarch64 in "aarch32" mode.</p>



<a name="235473849"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/When%20can%20we%20do%20a%20partial%20stabilization%20of%20Neon%20intrinsics%3F/near/235473849" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Sparrow Li <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/When.20can.20we.20do.20a.20partial.20stabilization.20of.20Neon.20intrinsics.3F.html#235473849">(Apr 21 2021 at 08:35)</a>:</h4>
<p>How should we get the behavior of these instructions in Clang? I think this requires disassembling the corresponding Clang program and putting the result into the tests. Could it be a way to get them from llvm's document?</p>



<a name="235491713"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/When%20can%20we%20do%20a%20partial%20stabilization%20of%20Neon%20intrinsics%3F/near/235491713" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Bramley <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/When.20can.20we.20do.20a.20partial.20stabilization.20of.20Neon.20intrinsics.3F.html#235491713">(Apr 21 2021 at 11:15)</a>:</h4>
<p>It's perhaps worth mentioning that most Arm documentation (including the reference manual) just refers to it as "Advanced SIMD" (no "2"), whether for Armv7 or Armv8 (AArch32 or AArch64). It does work differently in AArch32 and AArch64, so the intrinsics should reflect that, but Armv8's AArch32 NEON is a natural extension of Armv7's NEON so 32-bit Armv7 vs 32-bit Armv8 shouldn't be such a fundamental change. (There will be a few new instructions.)</p>



<a name="235492540"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/When%20can%20we%20do%20a%20partial%20stabilization%20of%20Neon%20intrinsics%3F/near/235492540" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Bramley <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/When.20can.20we.20do.20a.20partial.20stabilization.20of.20Neon.20intrinsics.3F.html#235492540">(Apr 21 2021 at 11:22)</a>:</h4>
<p>Note that Armv8 != AArch64. Armv8 includes both AArch32 and AArch64 states, Armv7 includes only AArch32 (named retrospectively).</p>



<a name="235495246"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/When%20can%20we%20do%20a%20partial%20stabilization%20of%20Neon%20intrinsics%3F/near/235495246" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/When.20can.20we.20do.20a.20partial.20stabilization.20of.20Neon.20intrinsics.3F.html#235495246">(Apr 21 2021 at 11:45)</a>:</h4>
<p><span class="user-mention" data-user-id="353056">@Sparrow Li</span> You don't need to get their behavior, just emit a C file that calls the intrinsics with random inputs and a Rust file that calls the intrinsics with the same inputs, then compare the results.</p>



<a name="236044682"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/When%20can%20we%20do%20a%20partial%20stabilization%20of%20Neon%20intrinsics%3F/near/236044682" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/When.20can.20we.20do.20a.20partial.20stabilization.20of.20Neon.20intrinsics.3F.html#236044682">(Apr 25 2021 at 07:05)</a>:</h4>
<p>I am aware their instructions are mostly the same... which is why my main concerns are their effects on floating point registers, potential ABI issues that might materialize (see <a href="https://github.com/rust-lang/rust/issues/64609">#64609</a> for how x86 has some particularly <em>amusing</em> examples in how this can cause unsoundness issues), and making sure we at least know what is happening there. Rust has mostly deferred caring about these details to LLVM, but now we have <code>cg_clif</code>, and a possible portable <code>core::simd</code> library, and we might be running out of room to ignore details like the D/Q vs. V layout of different Neon versions, or differences in floating point results.</p>



<a name="236059754"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/When%20can%20we%20do%20a%20partial%20stabilization%20of%20Neon%20intrinsics%3F/near/236059754" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/When.20can.20we.20do.20a.20partial.20stabilization.20of.20Neon.20intrinsics.3F.html#236059754">(Apr 25 2021 at 11:50)</a>:</h4>
<p>There are no ABI issues. ARM (32-bit) and AArch64 are completely different ISAs.</p>



<a name="236059764"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/When%20can%20we%20do%20a%20partial%20stabilization%20of%20Neon%20intrinsics%3F/near/236059764" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/When.20can.20we.20do.20a.20partial.20stabilization.20of.20Neon.20intrinsics.3F.html#236059764">(Apr 25 2021 at 11:50)</a>:</h4>
<p>I mean regarding the register layout.</p>



<a name="236059786"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/When%20can%20we%20do%20a%20partial%20stabilization%20of%20Neon%20intrinsics%3F/near/236059786" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/When.20can.20we.20do.20a.20partial.20stabilization.20of.20Neon.20intrinsics.3F.html#236059786">(Apr 25 2021 at 11:51)</a>:</h4>
<p>Passing vectors via GPR/stack vs vector registers is still an issue, but that's the same as x86.</p>



<a name="236067783"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/When%20can%20we%20do%20a%20partial%20stabilization%20of%20Neon%20intrinsics%3F/near/236067783" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/When.20can.20we.20do.20a.20partial.20stabilization.20of.20Neon.20intrinsics.3F.html#236067783">(Apr 25 2021 at 14:02)</a>:</h4>
<p>I am aware that's how it's <em>supposed</em> to work. I am also aware of bugs in LLVM codegen and the Rust compiler.<br>
And I don't think passing vectors in memory is long-term acceptable on account of the huge speed losses in code that is supposed to be fast.</p>
<p>So by "ABI issue" I mean anything that could block <strong>removing</strong> that behavior, because somewhere in the combinatorically explosive space of arguments and code inputs to Rust, LLVM, and the actual microprocessors we somehow induce an erroneous state. The kind of thing you file an issue over.</p>



<a name="236068880"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/When%20can%20we%20do%20a%20partial%20stabilization%20of%20Neon%20intrinsics%3F/near/236068880" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/When.20can.20we.20do.20a.20partial.20stabilization.20of.20Neon.20intrinsics.3F.html#236068880">(Apr 25 2021 at 14:22)</a>:</h4>
<p>If there are truly no such issues, then passing vectors through memory is a special case that we should no longer apply to Arm processors, and we can all celebrate and pop a bottle of champagne as we gain huge perf wins by circumventing that behavior on Arm. Should I go file that PR, or would I be introducing critical bugs by doing so?</p>



<a name="236069323"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/When%20can%20we%20do%20a%20partial%20stabilization%20of%20Neon%20intrinsics%3F/near/236069323" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/When.20can.20we.20do.20a.20partial.20stabilization.20of.20Neon.20intrinsics.3F.html#236069323">(Apr 25 2021 at 14:30)</a>:</h4>
<p>No, ARM has exactly the same issues as x86 with regards to the ABI.</p>



<a name="236069344"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/When%20can%20we%20do%20a%20partial%20stabilization%20of%20Neon%20intrinsics%3F/near/236069344" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/When.20can.20we.20do.20a.20partial.20stabilization.20of.20Neon.20intrinsics.3F.html#236069344">(Apr 25 2021 at 14:31)</a>:</h4>
<p>E.g. soft-float vs hard-float ARM, etc. This is a problem with C code as well: soft-float ABI code is explicitly incompatible with hard-float ABI code.</p>



<a name="236069416"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/When%20can%20we%20do%20a%20partial%20stabilization%20of%20Neon%20intrinsics%3F/near/236069416" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/When.20can.20we.20do.20a.20partial.20stabilization.20of.20Neon.20intrinsics.3F.html#236069416">(Apr 25 2021 at 14:32)</a>:</h4>
<p>But this is somewhat off-topic here since this topic is about the NEON intrinsics.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>